import * as React from "react";
import Sidebar from "../../components/sidebar";
import {Route} from "react-router-dom";
import UserManagePage from "./system/user";
import RoleManagePage from "./system/role";
import PropTypes from "prop-types";

/**
 * 后台页面框架
 * props:{
 *     history: 路由
 * }
 */
export default class AdminPage extends React.Component {
    static contextTypes = {
        router: PropTypes.object
    };
    componentDidMount() {
        this.context.router.history.listen(function(){
            console.log(arguments, document.title);
        })
    }

    render() {
        return (
            <div className={'d-flex'}>
                <Sidebar history={this.props.history}/>
                <main className="container-fluid w-auto flex-fill" style={{overflowY: "auto", height: "100vh"}}>
                    <Route path={this.props.match.path + "/system/user"} component={UserManagePage}/>
                    <Route path={this.props.match.path + "/system/role"} component={RoleManagePage}/>
                </main>
            </div>
        )
    }
}
